﻿package com.zit.service;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.zit.dao.DormDAO;
import com.zit.entity.Bedroom;
import com.zit.entity.Dorm;

/**
 * @author 王冲
 * 功能：宿舍管理
 * date2013-12-3 time下午04:49:58
 */
public class DormService extends BaseService {
	private DormDAO dorm = new DormDAO();
	
	/**
	 * 功能：查询公寓
	 * @return
	 */
	public List<Dorm> selectDorm(){
		
		List<Dorm> listDorm = new ArrayList<Dorm>();
		Session s = null;
		Transaction ts = null;
		
		try {
			s = getSession();
			listDorm = dorm.selectDorm(s);
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			s.close();
		}
		
		return listDorm;
	}
	
	/**
	 * 功能：增加公寓
	 * @return
	 */
	public List<Dorm> addDorm(){
		List<Dorm> listDorm = new ArrayList<Dorm>();
		Session s = null;
		Transaction ts = null;
		
		try {
			s = getSession();
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			s.close();
		}
		
		return listDorm;
	}
	
	/**
	 * 功能：查询公寓对应的宿舍
	 * @return
	 */
	public List<Bedroom> selectBedroom(int id){
		List<Bedroom> listBed = new ArrayList<Bedroom>();
		Session s = null;
		Transaction ts = null;
		
		try {
			s = getSession();
			listBed = dorm.selectBedroom(s, id);
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			s.close();
		}
		
		return listBed;
	}

}
